<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style type="text/css">

    #btn_go_back {
        color: -webkit-link;
        cursor: pointer;
        text-decoration: underline;
    }

</style>
<body>
<h2>User - Logout</h2>
<p>Please click logout button, which will clean up all login cookies.</p>

<table>
    <tbody>
    <tr>
        <td>通过后端API清除登录的cookie信息</td>
        <td>
            <button id="btn_logout_api">登出</button>
        </td>
    </tr>
    </tbody>
</table>

<ol>
    <li>
        <div id="btn_go_back">请点击这里回退到上一页面</div>
    </li>
    <li><a href="http://user.pphh.com:9000/user/login.html">Login</a></li>
    <li><a href="/user">Go User Home</a></li>
</ol>

</body>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">

    $("#btn_logout_api").click(function () {

        $.ajax({
            url: "/user/api/logout",
            type: "POST",
            data: null,
            processData: false,
            contentType: "application/json;charset=utf-8",
            success: function (data, status, ajax) {
                console.log("succeeded to logout.");
                alert("已成功登出，用户登录的cookie信息已清除。");
            },
            error: function (ajax, status, error) {
                console.log("fail to logout.");
                alert("登出失败");
            }
        });

    });

    $("#btn_go_back").click(function () {
        history.go(-1);
    });

</script>
</html>